package com.example.demo.Service.impl;

import com.example.demo.Common.Category;
import com.example.demo.Common.Dish;
import com.example.demo.Mapper.DishMapper;
import com.example.demo.Proj.CategoryPageParam;
import com.example.demo.Proj.DishPageParam;
import com.example.demo.Proj.PageReslut;
import com.example.demo.Service.DishService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DishServiceImpl implements DishService {
    @Autowired
    private DishMapper dishMapper;

    @Override
    public PageReslut getDishPage(DishPageParam dishPageParam) {
        PageHelper.startPage(dishPageParam.getPage(), dishPageParam.getPageSize());
        Page<Dish> dishPage = dishMapper.getDishPage(dishPageParam);
        return new PageReslut(dishPage.getTotal(), dishPage.getResult());
    }
}
